# Maintainer: Natanael Copa <ncopa@alpinelinux.org>
pkgname=xmlrpc-c
pkgver=1.51.08
pkgrel=4
pkgdesc="This library provides a modular implementation of XML-RPC for C and C++"
url="https://xmlrpc-c.sourceforge.net/"
arch="all"
license="BSD-3-Clause AND MIT"
depends_dev="libxml2-dev"
makedepends="libtool curl-dev libxml2-dev zlib-dev openssl-dev>3"
subpackages="
	$pkgname-dev
	$pkgname-doc
	$pkgname-client
	$pkgname-client++:clientxx
	xmlrpc-c++:cxx
	$pkgname-abyss
	$pkgname-tools
	"
source="https://downloads.sourceforge.net/project/xmlrpc-c/Xmlrpc-c%20Super%20Stable/$pkgver/xmlrpc-$pkgver.tgz
	format-security.patch
	"
builddir="$srcdir/xmlrpc-$pkgver"
options="!check"

prepare() {
	default_prepare
	update_config_sub
}

build() {
	./configure \
		--build=$CBUILD \
		--host=$CHOST \
		--prefix=/usr \
		--mandir=/usr/share/man \
		--disable-libxml2-backend \
		--disable-cgi-server \
		--disable-libwww-client \
		--disable-wininet-client
	make -j1 AR=ar RANLIB=ranlib
	make -j1 AR=ar RANLIB=ranlib -C tools
}

package() {
	make AR=ar RANLIB=ranlib DESTDIR="$pkgdir" install
	make AR=ar RANLIB=ranlib DESTDIR="$pkgdir" install -C tools
	install -m 644 -D doc/COPYING "$pkgdir"/usr/share/licenses/$pkgname/COPYING
}

tools() {
	pkgdesc="tools for xmlrpc-c"
	amove usr/bin
}

client() {
	pkgdesc="C client libraries for xmlrpc-c"
	replaces="$pkgname"

	amove usr/lib/libxmlrpc_client.so.*
}

clientxx() {
	replaces="libxml-c++"
	pkgdesc="C++ client libraries for xmlrpc-c"

	amove usr/lib/libxmlrpc_client++.so.*
}

cxx() {
	pkgdesc="This library provides a modular implementation of XML-RPC for C++"
	replaces="$pkgname"

	amove usr/lib/*++* \
		usr/lib/libxmlrpc_packetsocket.so.* \
		usr/lib/libxmlrpc_cpp.so.*
}

abyss() {
	pkgdesc="Abyss server libraries for C++"

	amove usr/lib/*abyss*
}

sha512sums="
df0d8e3730b529fb10fb2cf9511dc55143ad3c7b4cce5522b61ed0d212080f3ebf4b6aa8a28911ddbe90029fce6bea7df28ee51f36196900a855beff5bd3a1cd  xmlrpc-1.51.08.tgz
a47333110b84c530dc362104d5a9d99ae192a9db4c68fe536b98bfef0c076ff119162e4b6fec65ec98d9d5ccbcab32d5169db4d82a6e0fa080c89e9ff8f0cfef  format-security.patch
"
